import BuffUtil from '@/BuffUtil';
import Buff from '@/Buff';
import ArrayUtil from '@/ArrayUtil';
import ItemUtil from '@/ItemUtil';
import BaseUtil from '@/BaseUtil';
import SelectCommon from 'code/Core/Common/SelectCommon';
export default class Item_狂蛛复眼 {
    static id = 'C00O';
    static itemId = FourCC('C00O');
    static 名称: string = '警惕的专注';
    static 描述: string = '提升闪避和命中';
    static 图标: string = 'assets\\item\\INV_Misc_Eye_03.blp';
    static buffId: string = 'buff_item_kaungzhufuyan';
    static buffType: AppBuffType = {
        id: 'buff_item_kaungzhufuyan',
        name: Item_狂蛛复眼.名称,
        ubertip: Item_狂蛛复眼.描述,
        art: Item_狂蛛复眼.图标,
        targetArt: 'Abilities\\Spells\\Other\\GeneralAuraTarget\\GeneralAuraTarget.mdl',
        targetAttach: 'origin',
        dur: 2,
        attribute: {
            命中: 0.37,
            闪避_item_zhuyan: 0.1,
        },
        class: '光环',
    };
    static providers: unit[] = [];
    static buffInterval(buff: Buff) {
        DamageSystemInstance.applyPoisionDamage(buff.getParent(), buff.getCaster(), 150, null, true);
    }
    constructor() {
        BuffUtil.registerBuffType(Item_狂蛛复眼.buffType);
        se.onUnitPickupItem(Item_狂蛛复眼.pickItem);
        se.onUnitDropItem(Item_狂蛛复眼.dropItem);
        se.onUnitSellItem(Item_狂蛛复眼.dropItem);
        se.onUnitPawnItem(Item_狂蛛复眼.dropItem);
        BaseUtil.onTimer(1, Item_狂蛛复眼.timerEffect);
    }
    static timerEffect() {
        for (let p of Item_狂蛛复眼.providers) {
            let es = SelectCommon.getAllyUnitInRange(p, 750);
            for (let e of es) {
                BuffUtil.addBuff(e, Item_狂蛛复眼.buffId);
            }
        }
        return true;
    }
    static dropItem() {
        let item = GetManipulatedItem();
        if (GetItemTypeId(item) != Item_狂蛛复眼.itemId) return;
        let u = GetTriggerUnit();
        BaseUtil.runLater(0.1, () => {
            let count = ItemUtil.getItemCountOfTypeFromUnit(u, Item_狂蛛复眼.id);
            if (count == 0) ArrayUtil.removeElement(Item_狂蛛复眼.providers, u);
        });
    }
    static pickItem() {
        let u = GetTriggerUnit();
        let item = GetManipulatedItem();
        if (GetItemTypeId(item) != Item_狂蛛复眼.itemId) return;
        if (Item_狂蛛复眼.providers.includes(u)) return;
        Item_狂蛛复眼.providers.push(u);
    }
}
